Skip to main content

Docs Site Creation

Prerequisites#

  • A domain with DNS through Cloudflare

  • A GitHub account

  • Install NPM and yarn

Create a template site#

  1. Open a terminal in your GitHub directory

  2. install Docusaurus and run it for the first time to generate template files:

    yarn add docusaurusnpx @docusaurus/init@latest init my-website classic
  3. Start a demo server to make sure the site runs:

    cd my-websiteyarn start
  4. Make a new git repository and upload it to GitHub

    • in GitHub desktop you can use File -> New Repository

    • no need to make a .gitignore or readme.md, they will already be generated

    • NOTE: if you make this repository private (or plan on password-protecting the site) it may have implications on search functionality... but I did both anyway)

Add site to Cloudflare Pages#

  1. In the Cloudflare dashboard, go to pages, then create a project.

  2. Link your GitHub account

  3. Select the repository you just made

  4. Under framework preset, select Docusaurus, then you can Save and Deploy

  5. Wait for the site to build

  6. Under custom domains you can deploy your site to a domain or subdomain of your choosing and Cloudflare will automatically update your DNS records

Add password protection to your custom domain#

NOTE: if you do this you will need to set up your own search scraper (or not use search)

  1. In the Cloudflare dashboard, select your domain, then go to workers, then manage workers

  2. Create a new worker and name it

  3. Copy the password protection code from GitHub - dommmel/cloudflare-workers-basic-auth: Basic http auth via cloudflare workers and paste it into the left box

    • IMPORTANT: don't forget to change the credentials in index.js before saving!
  4. Go back to your domain's worker page in the Cloudflare dashboard, and select add route

  5. If you are using the entire domain for this site than you can use the default of *.my-domain.com/*

    • if you are using a subdomain, use subdomain.my-domain.com/*
  6. Select the worker you just made

  7. Save

  8. Test and make sure the password protection is working


Resources#